package com.code.leetcode.before50;

import java.util.HashSet;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/7/24 9:54
 */
public class The73 {
    public void setZeroes(int[][] matrix) {

        HashSet<Integer> row = new HashSet<>();
        HashSet<Integer> col = new HashSet<>();

        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                if (matrix[i][j] == 0) {
                    row.add(i);
                    col.add(j);
                }
            }
        }
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                if (row.contains(i) || col.contains(j))
                    matrix[i][j] = 0;
            }
        }
    }
}
